//
//  CourseDetailsCatalogCollectionViewCell.m
//  ZFPlayer_Example
//
//  Created by 洪欣 on 2019/1/4.
//  Copyright © 2019年 紫枫. All rights reserved.
//

#import "CourseDetailsCatalogCollectionViewCell.h"
#import "CourseDetailsCatalogTableViewCell.h"
#import "LBFuwenbenCell.h"
@interface CourseDetailsCatalogCollectionViewCell ()<UITableViewDataSource, UITableViewDelegate>
@property (weak, nonatomic) IBOutlet UITableView *tableView;
@property (strong, nonatomic) CourseDetailsCourseHourOutputDTODataModel *currentModel;
@end

@implementation CourseDetailsCatalogCollectionViewCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
    
    self.tableView.dataSource = self;
    self.tableView.delegate = self; 
    
    self.tableView.rowHeight = 65.f;
    
    [self.tableView registerNib:[UINib nibWithNibName:NSStringFromClass([CourseDetailsCatalogTableViewCell class]) bundle:nil] forCellReuseIdentifier:@"CellId"];
        [self.tableView registerNib:[UINib nibWithNibName:NSStringFromClass([LBFuwenbenCell class]) bundle:nil] forCellReuseIdentifier:@"CellId2"];
    
    UIView *footer = [UIView new];
    footer.backgroundColor = [UIColor whiteColor];
    footer.frame = CGRectMake(0, 0, ScreenW, 200);
    self.tableView.tableFooterView = footer;
}
- (void)resetState { 
    [self.tableView reloadData];
}
- (void)setModel:(CourseDetailsCourseOutputDTODataModel *)model {
    _model = model;
    [self.tableView reloadData];
}
//- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
//    return 2;
//}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {

    return self.model.courseHourOutputDTOList.count;
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

    
        CourseDetailsCatalogTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"CellId"];
        cell.model = self.model.courseHourOutputDTOList[indexPath.row];
        return cell;
    
//    else{
//        LBFuwenbenCell *cell = [tableView dequeueReusableCellWithIdentifier:@"CellId2"];
////        cell.model = self.model.courseHourOutputDTOList[indexPath.row];
//        cell.backgroundColor = [UIColor orangeColor];
//        return cell;
//    }

}
//- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
//    return 100;
//}


#pragma 点击课程详情播放视频或音频
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {

    
    CourseDetailsCourseHourOutputDTODataModel *model = self.model.courseHourOutputDTOList[indexPath.row];

    if (self.currentModel == model) {
        return;
    }
    self.currentModel.selected = NO;
    model.selected = YES;
    self.currentModel = model;
    [self.tableView reloadData];
    if (self.selectTableViewCellBlock) {
        self.selectTableViewCellBlock(model, self);
    }
}

@end
